//
//  HsLCTitleWithRightDesViewCell.m
//  TestIos
//
//  Created by hs on 2020/10/22.
//  Copyright © 2020 Liyadong. All rights reserved.
//

#import "HsLCTitleWithRightDesViewCell.h"
#import "Masonry.h"

#define setting_page_cell_title_left   16

@interface HsLCTitleWithRightDesViewCell ()

@property (nonatomic, strong) UILabel *nameLabel;

@property (nonatomic, strong) UILabel *desLabel;

/** 详情箭头 */
@property (nonatomic, strong) UIImageView *detailView;

@property (nonatomic, strong) UILabel *bottomLine;

@end

@implementation HsLCTitleWithRightDesViewCell

+(instancetype)cellWithTableView:(UITableView *)tableview {
    static NSString *cellID = @"HsLCTitleWithRightDesViewCell";
    HsLCTitleWithRightDesViewCell *cell = [tableview dequeueReusableCellWithIdentifier:cellID];
    if(cell == nil) {
        cell = [[HsLCTitleWithRightDesViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        //        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}


- (void)updateCellWithTitleStr:(NSString *)titleStr subTitle:(NSString *)subTitle {
    
    self.nameLabel.text = titleStr;
    self.desLabel.text = subTitle;
 
        
 
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
/**
 *  构造方法(在初始化对象的时候会调用)
 *  一般在这个方法中添加需要显示的子控件
 */
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self.contentView addSubview:self.nameLabel];
        [self.contentView addSubview:self.desLabel];
        [self.contentView addSubview:self.detailView];
        [self.contentView addSubview:self.bottomLine];

        [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(setting_page_cell_title_left);
            make.right.mas_equalTo(-50);
            make.centerY.mas_equalTo(self.mas_centerY);
            make.height.mas_equalTo(21);
        }];
 
        
        
        
        [self.detailView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.contentView.mas_centerY);
            make.right.mas_equalTo(-setting_page_cell_title_left);
            make.width.mas_equalTo(4);
            make.height.mas_equalTo(8);
        }];
        
        [self.desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.detailView.mas_left).mas_offset(-6);
            make.centerY.mas_equalTo(self.mas_centerY);
            make.bottom.mas_equalTo(-12);
            make.left.mas_equalTo(50);
        }];
        
        
        [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(0);
            make.left.mas_equalTo(setting_page_cell_title_left);
            make.right.mas_equalTo(-setting_page_cell_title_left);
            make.height.mas_equalTo(0.5);
        }];
        
   
    }
    return self;
}

  

- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _nameLabel.textColor = [UIColor colorWithHexString:@"#2A2B30"];
        UIFont *font = [UIFont systemFontOfSize:15 weight:UIFontWeightRegular];
        _nameLabel.font = font;
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        _nameLabel.text = @"个人信息";
        [_nameLabel sizeToFit];
    }
    return _nameLabel;
}
- (UILabel *)desLabel {
    if (!_desLabel) {
        _desLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _desLabel.textColor = [UIColor colorWithHexString:@"#585C6C"];
        UIFont *font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
        _desLabel.textAlignment = NSTextAlignmentRight;
        _desLabel.font = font;
        NSString *subStr = @"描述";
        _desLabel.numberOfLines = 0;
        _desLabel.text = subStr;
        [_desLabel sizeToFit];
    }
    return _desLabel;
}


- (UILabel *)bottomLine {
    if (!_bottomLine) {
        _bottomLine = [[UILabel alloc] initWithFrame:CGRectZero];
        _bottomLine.backgroundColor = [UIColor colorWithHexString:@"#F1F1F5"];
     }
    return _bottomLine;
}
 
- (UIImageView *)detailView {
    if (!_detailView) {
        _detailView = [[UIImageView alloc] initWithFrame:CGRectZero];
        _detailView.image = [UIImage imageNamed:@"lczq_arrow_right_icon"];
    }
    return _detailView;
}

//- (void)drawRect:(CGRect)rect {
//
//    CGContextRef context = UIGraphicsGetCurrentContext();
//
//    CGContextSetFillColorWithColor(context, [UIColor clearColor].CGColor);
//
//    CGContextFillRect(context, rect);
//
//    //上分割线，
//    CGContextSetStrokeColorWithColor(context, [UIColor clearColor].CGColor);
//    CGContextStrokeRect(context, CGRectMake(5, -1, rect.size.width - 10, 1));
//
//    //下分割线
//    CGContextSetStrokeColorWithColor(context,[UIColor colorWithHexString:@"#e5e5e5"].CGColor);
//
//    CGContextStrokeRect(context,CGRectMake(main_title_left_margin, rect.size.height-0.5, rect.size.width - 2 * main_title_left_margin ,1));
//
//}


@end
